package NovelBar.controller;

import NovelBar.entity.User;
import NovelBar.entity.Witer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import NovelBar.service.UserService;

import java.util.List;

@RestController
public class UserController {
	@Autowired
	private UserService userService;
	
	@RequestMapping("/public/updateNameByName")
	public void updateNameByName (String oldUsername, String newUsername) {
		userService.updateUsernameByUsername(oldUsername, newUsername);
	}
	@RequestMapping("/witer/loadWiterById")
	public Witer loadWiterById(Integer uid) {
		return userService.loadWiterById(uid);
	}
	@RequestMapping("/admin/banWiter")
	public void banWiter(Integer bookid) {
		userService.banWiter(bookid);
	}

	@RequestMapping("/admin/banUserList")
	public List<User> banUserList() {
		return userService.banUserList();
	}

	@RequestMapping("/admin/removeBan")
	public List<User> removeBan (Integer id){
		userService.removeBan(id);
		return userService.banUserList();
	}

	@RequestMapping("/public/charge")
	public void charge(Integer id, Integer money) {
		userService.charge(id, money);
	}
}
